﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SQLite;

public partial class SaleInfo_AuditDetail : UDCPage
{
    private int _did = -1;
    protected int DID
    {
        get { return _did; }
        set { _did = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DID = String.IsNullOrEmpty(Request.QueryString["Did"])
                ? GetDid() : Int32.Parse(Request.QueryString["Did"].ToString());
            SaleInfoDataBind();
            added.HRef = "NewSale.aspx?add=Yes&did=" + DID.ToString();
            if (!IsAuditor() || HaveAudited())
            {
                added.Visible = false;
            }
        }
    }

    private void SaleInfoDataBind()
    { 
        string sqlstr = @"select sid,ServiceId,case isnew when 1 then '新用户' else '老用户' end as isnew
                    ,case iscontract when 1 then '预存话费送手机' else '购机入网送话费' end as iscontract
                    ,saledesc,t3.dvname from ud_saleinfo_t t1 
                    inner join ud_developer_t t3 on t1.DvId = t3.DvId and t3.Did = :Did and t3.ifvalid = 1
                    where date(saledate) = date('now','localtime','-1 day')";
        SQLiteParameter[] spc = { 
                                    new SQLiteParameter(":Did",DbType.Int32)
                                };
        spc[0].Value = DID;
        DataSet ds = SQLiteHelper.ExecuteDataset(sqlstr, spc);
        UnitDaySales.DataSource = ds;
        UnitDaySales.DataBind();
    }
}